# 字典  -----> Java Map
from collections import OrderedDict

favorite_languages = {
    'jen': 'python',
    'sarh': 'c',
    'jonhl': 'java',
    'phil': 'rugh',
    'alion': 'python',
    }

# 遍历键值对
for name, language in favorite_languages.items():
    print(name.title() + "`s favorite languages is " + language.title() + ".")
print("-------------------")
# 遍历键
for name in favorite_languages.keys():
    print("key : " + name.title())

# 按照顺序遍历字典中的键 sorted()
for name in sorted(favorite_languages.keys()):
    print(name.title() + ",thank you for taking the poll.")

# 遍历值
for language in favorite_languages.values():
    print('value: ' + language.title())
# 遍历值并去重 set()
for language in set(favorite_languages.values()):
    print("distinct value: " + language)

print("=======================")
friends = ['phil', 'sarh']

for name, language in favorite_languages.items():
    print(name.title())
    if name in friends:
        print(" Hi " + name.title() + ",I see your favorite language is " + favorite_languages[name].title() + ".")


# print('sarh favorite languages is :' + favorite_languages['sarh'].title() + '.')

if 'eril' not in favorite_languages.keys():
    print("Eirn ,please take your pour")
